//
//  JXHPicturePickerCell.swift
//  JXHSinaWeiBo
//
//  Created by juxiaohui on 16/10/28.
//  Copyright © 2016年 juxiaohui. All rights reserved.
//

import UIKit

class JXHPicturePickerCell: UICollectionViewCell {
    
    var image : UIImage?{
        
        didSet{
            if image != nil {
                picture.image = image
                addPtotoBtn.isUserInteractionEnabled = false
                removeBtn.isHidden = false
            }else{
                picture.image = nil
                addPtotoBtn.isUserInteractionEnabled = true
                removeBtn.isHidden = true
            }
        }
    }
    
    @IBOutlet weak var addPtotoBtn: UIButton!
    
    @IBOutlet weak var removeBtn: UIButton!
    
    @IBOutlet weak var picture: UIImageView!
    
    @IBAction func addPhotoClick(_ sender: UIButton) {
        //发通知
        let noteName = Notification.Name.init(picturePickerAddPhoto)
        NotificationCenter.default.post(name: noteName, object: nil)
    }
    
    @IBAction func removeBtnClick() {
        
        let noteName = Notification.Name.init(picturePickerRemovePhoto)
        NotificationCenter.default.post(name: noteName, object: picture.image)
        
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

}
